package com.zyq.validation.annotation;

import com.zyq.validation.validator.CannotBlankValidator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

//此注解可用在方法上， 成员变量上， 注解上， 构造方法上， 方法参数上
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
//在运行时生效
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Constraint(validatedBy = {CannotBlankValidator.class})
public @interface CannotBlank {
    //默认错误信息
    String  message() default "不能包含空格";
    //分组
    Class<?>[] groups() default {};
    //负载
    Class <? extends Payload>[]   payload() default{};

    //指定多个时使用
    @Target({ElementType.METHOD, ElementType.FIELD, ElementType.ANNOTATION_TYPE,ElementType.CONSTRUCTOR, ElementType.PARAMETER})
    @Retention(RetentionPolicy.RUNTIME)
    @Documented
    @interface List {
        CannotBlank[] value();
    }
}
















